<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 *订单管理
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
$manage_op=array('confirm','cancel','agree','disagree');
if(in_array($_RQ['op'],$manage_op)){
	$id=intval($_RQ['id']);
	if(!$id){
		exi('请先选择订单！','error');
	}
}
$return=array();
$tabs=array(
	array('op'=>'list','title'=>'订单总列表'),
	array('op'=>'list0','title'=>'待支付订单列表'),
	array('op'=>'list1','title'=>'已支付订单列表'),
	array('op'=>'list2','title'=>'已取消订单列表'),
	
);
$return['status']=array('0'=>'待支付','1'=>'已支付','2'=>'已取消');
if($_RQ['op']=='list'){
	$params=array();
	$params['uniacid']=$_SESSION['uniacid'];
	if(!empty($_RQ['name'])){
		$params['name like']='%'.trim($_RQ['name']).'%';
		$return['params']['name']=$_RQ['name'];
	}
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$total='';
	$fields=array('id','uniacid','land_id','seed_id','mid','animal_id','ordersn','money','pay','username','mobile','address','status','createtime');
	$list=pdo_getslice('jy_farmer_order',$params,array($pindex,$psize),$total,$fields,'','id desc');
	if($list){
		foreach($list as &$item){
			$land=pdo_getcolumn('jy_farmer_land',array('id'=>$item['land_id'],'uniacid'=>$_SESSION['uniacid']));
			$item['lclassify_title']=pdo_getcolumn('jy_farmer_lclassify',array('id'=>$land['classify_id'],'uniacid'=>$_SESSION['uniacid']),'title');
			$item['land_title']=$land['title'];
			$land=pdo_getcolumn('jy_farmer_animal',array('id'=>$item['land_id'],'uniacid'=>$_SESSION['uniacid']));
			$item['lclassify_title']=pdo_getcolumn('jy_farmer_lclassify',array('id'=>$land['classify_id'],'uniacid'=>$_SESSION['uniacid']),'title');
			$item['land_title']=$land['title'];
		}
	}
	$return['list']=$list;
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$htmls=array(
		'type'=>'list',
		'tabs'=>$tabs,
		'list'=>array('data'=>'list','edit'=>false,'del_one'=>false,'delall'=>false,'list'=>array(
			array('name'=>'ordersn','title'=>'订单编号','type'=>'string'),
			array('name'=>'nickname','title'=>'用户昵称','type'=>'string'),
			array('name'=>'username','title'=>'用户姓名','type'=>'string'),
			array('name'=>'lclassify_title','title'=>'地块名称','type'=>'string'),
			array('name'=>'land_title','title'=>'土地名称','type'=>'string'),
			array('name'=>'aclassify_title','title'=>'家禽分类','type'=>'string'),
			array('name'=>'animal_title','title'=>'家禽名称','type'=>'string'),
			array('name'=>'user_mobile','title'=>'用户电话','type'=>'string'),
			array('name'=>'serve_title','title'=>'门店名称','type'=>'string'),
			array('name'=>'createtime','title'=>'下单时间','type'=>'string'),
			array('name'=>'money','title'=>'需支付金额','type'=>'string'),
			array('name'=>'status','title'=>'状态','type'=>'radio','options'=>'status'),
		)),
		'search_one'=>array('name'=>'nickname'),
	);
	$return['htmls']=$htmls;
	set_html('framess',$this->menu());
	exi($return);
}
if($_RQ['op']=='list0'){
	$params=array();
	$params['uniacid']=$_SESSION['uniacid'];
	if(!empty($_RQ['name'])){
		$params['name like']='%'.trim($_RQ['name']).'%';
		$return['params']['name']=$_RQ['name'];
	}
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$total='';
	$fields=array('id','uniacid','land_id','seed_id','mid','animal_id','ordersn','money','pay','username','mobile','address','status','createtime');
	$list=pdo_getslice('jy_farmer_order',$params,array($pindex,$psize),$total,$fields,'','id desc');
	if($list){
		foreach($list as &$item){
			$land=pdo_getcolumn('jy_farmer_land',array('id'=>$item['land_id'],'uniacid'=>$_SESSION['uniacid']));
			$item['lclassify_title']=pdo_getcolumn('jy_farmer_lclassify',array('id'=>$land['classify_id'],'uniacid'=>$_SESSION['uniacid']),'title');
			$item['land_title']=$land['title'];
			$land=pdo_getcolumn('jy_farmer_animal',array('id'=>$item['land_id'],'uniacid'=>$_SESSION['uniacid']));
			$item['lclassify_title']=pdo_getcolumn('jy_farmer_lclassify',array('id'=>$land['classify_id'],'uniacid'=>$_SESSION['uniacid']),'title');
			$item['land_title']=$land['title'];
		}
	}
	$return['list']=$list;
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$htmls=array(
		'type'=>'list',
		'tabs'=>$tabs,
		'list'=>array('data'=>'list','edit'=>false,'del_one'=>false,'delall'=>false,'list'=>array(
			array('name'=>'ordersn','title'=>'订单编号','type'=>'string'),
			array('name'=>'nickname','title'=>'用户昵称','type'=>'string'),
			array('name'=>'username','title'=>'用户姓名','type'=>'string'),
			array('name'=>'lclassify_title','title'=>'地块名称','type'=>'string'),
			array('name'=>'land_title','title'=>'土地名称','type'=>'string'),
			array('name'=>'aclassify_title','title'=>'家禽分类','type'=>'string'),
			array('name'=>'animal_title','title'=>'家禽名称','type'=>'string'),
			array('name'=>'user_mobile','title'=>'用户电话','type'=>'string'),
			array('name'=>'serve_title','title'=>'门店名称','type'=>'string'),
			array('name'=>'createtime','title'=>'下单时间','type'=>'string'),
			array('name'=>'money','title'=>'需支付金额','type'=>'string'),
			array('name'=>'status','title'=>'状态','type'=>'radio','options'=>'status'),
		)),
		'search_one'=>array('name'=>'nickname'),
	);
	$return['htmls']=$htmls;
	set_html('framess',$this->menu());
	exi($return);
}
if($_RQ['op']=='list1'){
	$params=array();
	$params['uniacid']=$_SESSION['uniacid'];
	if(!empty($_RQ['name'])){
		$params['name like']='%'.trim($_RQ['name']).'%';
		$return['params']['name']=$_RQ['name'];
	}
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$total='';
	$fields=array('id','uniacid','land_id','seed_id','mid','animal_id','ordersn','money','pay','username','mobile','address','status','createtime');
	$list=pdo_getslice('jy_farmer_order',$params,array($pindex,$psize),$total,$fields,'','id desc');
	if($list){
		foreach($list as &$item){
			$land=pdo_getcolumn('jy_farmer_land',array('id'=>$item['land_id'],'uniacid'=>$_SESSION['uniacid']));
			$item['lclassify_title']=pdo_getcolumn('jy_farmer_lclassify',array('id'=>$land['classify_id'],'uniacid'=>$_SESSION['uniacid']),'title');
			$item['land_title']=$land['title'];
			$land=pdo_getcolumn('jy_farmer_animal',array('id'=>$item['land_id'],'uniacid'=>$_SESSION['uniacid']));
			$item['lclassify_title']=pdo_getcolumn('jy_farmer_lclassify',array('id'=>$land['classify_id'],'uniacid'=>$_SESSION['uniacid']),'title');
			$item['land_title']=$land['title'];
		}
	}
	$return['list']=$list;
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$htmls=array(
		'type'=>'list',
		'tabs'=>$tabs,
		'list'=>array('data'=>'list','edit'=>false,'del_one'=>false,'delall'=>false,'list'=>array(
			array('name'=>'ordersn','title'=>'订单编号','type'=>'string'),
			array('name'=>'nickname','title'=>'用户昵称','type'=>'string'),
			array('name'=>'username','title'=>'用户姓名','type'=>'string'),
			array('name'=>'lclassify_title','title'=>'地块名称','type'=>'string'),
			array('name'=>'land_title','title'=>'土地名称','type'=>'string'),
			array('name'=>'aclassify_title','title'=>'家禽分类','type'=>'string'),
			array('name'=>'animal_title','title'=>'家禽名称','type'=>'string'),
			array('name'=>'user_mobile','title'=>'用户电话','type'=>'string'),
			array('name'=>'serve_title','title'=>'门店名称','type'=>'string'),
			array('name'=>'createtime','title'=>'下单时间','type'=>'string'),
			array('name'=>'money','title'=>'需支付金额','type'=>'string'),
			array('name'=>'status','title'=>'状态','type'=>'radio','options'=>'status'),
		)),
		'search_one'=>array('name'=>'nickname'),
	);
	$return['htmls']=$htmls;
	set_html('framess',$this->menu());
	exi($return);
}
if($_RQ['op']=='list2'){
	$params=array();
	$params['uniacid']=$_SESSION['uniacid'];
	if(!empty($_RQ['name'])){
		$params['name like']='%'.trim($_RQ['name']).'%';
		$return['params']['name']=$_RQ['name'];
	}
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$total='';
	$fields=array('id','uniacid','land_id','seed_id','mid','animal_id','ordersn','money','pay','username','mobile','address','status','createtime');
	$list=pdo_getslice('jy_farmer_order',$params,array($pindex,$psize),$total,$fields,'','id desc');
	if($list){
		foreach($list as &$item){
			$land=pdo_getcolumn('jy_farmer_land',array('id'=>$item['land_id'],'uniacid'=>$_SESSION['uniacid']));
			$item['lclassify_title']=pdo_getcolumn('jy_farmer_lclassify',array('id'=>$land['classify_id'],'uniacid'=>$_SESSION['uniacid']),'title');
			$item['land_title']=$land['title'];
			$land=pdo_getcolumn('jy_farmer_animal',array('id'=>$item['land_id'],'uniacid'=>$_SESSION['uniacid']));
			$item['lclassify_title']=pdo_getcolumn('jy_farmer_lclassify',array('id'=>$land['classify_id'],'uniacid'=>$_SESSION['uniacid']),'title');
			$item['land_title']=$land['title'];
		}
	}
	$return['list']=$list;
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$htmls=array(
		'type'=>'list',
		'tabs'=>$tabs,
		'list'=>array('data'=>'list','edit'=>false,'del_one'=>false,'delall'=>false,'list'=>array(
			array('name'=>'ordersn','title'=>'订单编号','type'=>'string'),
			array('name'=>'nickname','title'=>'用户昵称','type'=>'string'),
			array('name'=>'username','title'=>'用户姓名','type'=>'string'),
			array('name'=>'lclassify_title','title'=>'地块名称','type'=>'string'),
			array('name'=>'land_title','title'=>'土地名称','type'=>'string'),
			array('name'=>'aclassify_title','title'=>'家禽分类','type'=>'string'),
			array('name'=>'animal_title','title'=>'家禽名称','type'=>'string'),
			array('name'=>'user_mobile','title'=>'用户电话','type'=>'string'),
			array('name'=>'serve_title','title'=>'门店名称','type'=>'string'),
			array('name'=>'createtime','title'=>'下单时间','type'=>'string'),
			array('name'=>'money','title'=>'需支付金额','type'=>'string'),
			array('name'=>'status','title'=>'状态','type'=>'radio','options'=>'status'),
		)),
		'search_one'=>array('name'=>'nickname','placeholder'=>'请搜索用户昵称'),
	);
	$return['htmls']=$htmls;
	set_html('framess',$this->menu());
	exi($return);
}
//待消费
